﻿<UserControl x:Class="Locator.Silverlight.Client.ManageProductsControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:converters="clr-namespace:Locator.Silverlight.Client.Converters"
    mc:Ignorable="d"
             
     DataContext="{Binding ManageProductsViewModel, Source={StaticResource Locator}}" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">
    <UserControl.Resources>
        <converters:AddButtonStateConverter x:Key="AddButtonStateConverter"/>
        <converters:AddButtonContentConverter x:Key="AddButtonContentConverter"/>
        <DataTemplate x:Name="ProductTemplate">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Name}" Width="400" VerticalAlignment="Center" />
                <Button Content="Remove" Width="55" Command="{Binding ManageProductsViewModel.RemoveProductCommand, Source={StaticResource Locator}}" CommandParameter="{Binding}"/>
            </StackPanel>
        </DataTemplate>
        <DataTemplate x:Name="NewProductTemplate">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Name}" Width="400" VerticalAlignment="Center" />
                <Button Content="{Binding UsedByUser, Converter={StaticResource AddButtonContentConverter}}" IsEnabled="{Binding UsedByUser, Converter={StaticResource AddButtonStateConverter}}" Width="55" Command="{Binding ManageProductsViewModel.AddProductCommand, Source={StaticResource Locator}}" CommandParameter="{Binding}"/>
            </StackPanel>
        </DataTemplate>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="White">
        <ListBox Height="173" HorizontalAlignment="Left"  Name="listBoxCurrentProducts" VerticalAlignment="Top" Width="482" ItemsSource="{Binding UserProducts}" ItemTemplate="{StaticResource ProductTemplate}" Margin="4,353,0,0" />
        <sdk:AutoCompleteBox Height="28" HorizontalAlignment="Left" Margin="4,0,0,0" Name="autoCompleteBoxProducts" VerticalAlignment="Top" Width="482" Text="{Binding SearchText, Mode=TwoWay}" SelectedItem="{Binding CurrentNewSubstanceForSearch, Mode=TwoWay}" ItemsSource="{Binding AllSubstances}" ValueMemberPath="Name" FilterMode="Contains" TabIndex="0" MinimumPrefixLength="2">
            <sdk:AutoCompleteBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Name}"/>
                </DataTemplate>
            </sdk:AutoCompleteBox.ItemTemplate>
        </sdk:AutoCompleteBox>
        <ListBox Height="214" HorizontalAlignment="Left" Margin="4,76,0,0" Name="listBoxSearchResults" VerticalAlignment="Top" Width="482" ItemsSource="{Binding SearchResults}" ItemTemplate="{StaticResource NewProductTemplate}" TabIndex="2" />
        <Button Content="Search" Height="23" HorizontalAlignment="Left" Margin="490,0,4,0" Name="buttonSearch" VerticalAlignment="Top" Width="75" Command="{Binding FindProductsCommand}" TabIndex="1" />
        <TextBlock Height="23" HorizontalAlignment="Left" Margin="4,324,0,0" Name="textBlockYourProducts" Text="Your Products" VerticalAlignment="Top" />
        <TextBlock Height="23" HorizontalAlignment="Left" Margin="4,47,0,0" Name="textBlockSearchResults" Text="Search Results" VerticalAlignment="Top" />
    </Grid>
</UserControl>
